<?php
namespace addons\advertising;

use think\Addons;

class Advertising extends Addons
{   
    public $info = [
        'name' => 'advertising',
        'title' => '首页广告插件',
        'description' => '首页轮播图下方以及右侧广告位插件',
        'author' => 'Teen',
        'version' => '1.0.0'
    ];

    public function install()
    {
        $config = ["name" => "advertising","status" => 1];
        $result=create_config($config);
        return $result;
    }

    public function uninstall()
    {
        $name = $this->getName();
        $file=ADDON_PATH.$name.DS."config.php";

        if(!is_file($file)){
            return false;
        }

        $result=@unlink($file);
        if ($result){
            return true;
        }
        return false;
    }

    public function ad1($param)
    {
        $ad = ["href" => "#","src" => "/uploads/ad/ad1.png"];
        $this->assign('ad', $ad);
        return $this->fetch('ad1');
    }
  
   public function ad2($param)
    {
        $ad = ["href" => "#","src" => "/uploads/ad/ad2.png"];
        $this->assign('ad2', $ad);
        return $this->fetch('ad2');
    }

}